package com.debao.system.service.impl;

import java.util.List;

import com.debao.common.utils.KeyGreaterUtil;
import com.debao.common.utils.SecurityUtils;
import com.debao.common.utils.uuid.IdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.debao.system.mapper.UserCardMapper;
import com.debao.system.domain.UserCard;
import com.debao.system.service.IUserCardService;

/**
 * 会员账户Service业务层处理
 * 
 * @author DeBao
 * @date 2024-08-14
 */
@Service
public class UserCardServiceImpl implements IUserCardService 
{
    @Autowired
    private UserCardMapper userCardMapper;

    /**
     * 查询会员账户
     * 
     * @param id 会员账户主键
     * @return 会员账户
     */
    @Override
    public UserCard selectUserCardById(Long id)
    {
        return userCardMapper.selectUserCardById(id);
    }

    /**
     * 根据用户查询会员账户
     * @param userId
     * @return
     */
    @Override
    public UserCard selectUserCardByUserId(Long userId) {
        return userCardMapper.selectUserCardByUserId(userId);
    }

    /**
     * 查询会员账户列表
     * 
     * @param userCard 会员账户
     * @return 会员账户
     */
    @Override
    public List<UserCard> selectUserCardList(UserCard userCard)
    {
        return userCardMapper.selectUserCardList(userCard);
    }

    /**
     * 新增会员账户
     * 
     * @param userCard 会员账户
     * @return 结果
     */
    @Override
    public int insertUserCard(UserCard userCard)
    {
        userCard.setMemberCard("No."+KeyGreaterUtil.getRandom620(6));
        return userCardMapper.insertUserCard(userCard);
    }

    /**
     * 修改会员账户
     * 
     * @param userCard 会员账户
     * @return 结果
     */
    @Override
    public int updateUserCard(UserCard userCard)
    {
        return userCardMapper.updateUserCard(userCard);
    }

    /**
     * 批量删除会员账户
     * 
     * @param ids 需要删除的会员账户主键
     * @return 结果
     */
    @Override
    public int deleteUserCardByIds(Long[] ids)
    {
        return userCardMapper.deleteUserCardByIds(ids);
    }

    /**
     * 删除会员账户信息
     * 
     * @param id 会员账户主键
     * @return 结果
     */
    @Override
    public int deleteUserCardById(Long id)
    {
        return userCardMapper.deleteUserCardById(id);
    }
    @Override
    public int totalCount(String beforeDate){
        return userCardMapper.totalCount(beforeDate);
    }
}
